//
//  QuDanConfirmDestineTimeViewCell.m
//  QuDanOEM
//
//  Created by mac on 2021/11/19.
#import "QuDanConfirmDestineTimeViewCell.h"
#import "QuDanDestimeSubViewCell.h"
@interface QuDanConfirmDestineTimeViewCell ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong)UICollectionView *timeCollectionView;
@end
@implementation QuDanConfirmDestineTimeViewCell
- (UICollectionView *)timeCollectionView
{
    if (!_timeCollectionView) {
        UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
        flow.sectionHeadersPinToVisibleBounds = NO;//头视图悬浮
        flow.scrollDirection = UICollectionViewScrollDirectionVertical;
        flow.minimumLineSpacing = 10;//行间距
        flow.minimumInteritemSpacing = 10;//列间距
        _timeCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flow];
        _timeCollectionView.backgroundColor =  [UIColor clearColor];
        _timeCollectionView.showsVerticalScrollIndicator = NO;
        _timeCollectionView.showsHorizontalScrollIndicator = NO;
        _timeCollectionView.delegate = self;
        _timeCollectionView.dataSource = self;
        [_timeCollectionView registerNib:[UINib nibWithNibName:@"QuDanDestimeSubViewCell" bundle:nil] forCellWithReuseIdentifier:@"QuDanDestimeSubViewCell"];
    }
    return _timeCollectionView;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupTimeCollectionView];
}
-(void)setupTimeCollectionView
{
    [self.bgView addSubview:self.timeCollectionView];
    [self.timeCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.top.offset(0);
    }];
}
#pragma mark -- UICollectionViewDelegate,UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 7;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    QuDanDestimeSubViewCell *destimeSubCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QuDanDestimeSubViewCell" forIndexPath:indexPath];
    return destimeSubCell;
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(10, 20, 20, 20);
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return  CGSizeMake((QD_IPHONE_WIDTH-120-80)/3,30);
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
}
@end
